package org.lg.framework.provider;

import org.lg.framework.register.LocalRegister;
import org.lg.service.TeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ComponentScan;

import java.util.Arrays;
import java.util.Locale;

//https://tools.kalvinbg.cn/txt/ascii
@SpringBootApplication//会扫描但只扫描同包 和 子包

//@Configuration
//@EnableAutoConfiguration //配置该注解可以启动容器 并加载bean 但无法获得context
@ComponentScan("org.lg")
public class ProviderApplication {
    public static ApplicationContext appContext;

    public static void printBean()
    {
        String[] beans = appContext.getBeanDefinitionNames();
        Arrays.sort(beans);
        for (String bean : beans)
        {
            System.out.println(bean + " of Type :: " + appContext.getBean(bean).getClass());
        }
    }

    public static void main(String[] args) {
        //先注册 因为服务器会await
        LocalRegister.register("org.lg.service.TeamService", TeamService.class);
        //spring boot 启动的返回值就是容器,但是 执行的代码中 有await 此时变量还未返回就不能用要在await之前 提供 用工具类方式提供
        ProviderApplication.appContext =  SpringApplication.run(ProviderApplication.class, args);
        //ProviderApplication.printBean();

   }

}
